<script setup lang="js">
import {ref , onMounted} from 'vue'
import {Vue3SeamlessScroll} from "vue3-seamless-scroll";
import anlyze from "../../apis/anlyze.js"


const toDayList = ref([])
const fetchTaDayList = async () => {
  try {
    const res = await anlyze.getVolunteersToDayRegisterList()
    toDayList.value = res
  } catch (error) {
    console.error('获取数据失败:', error)
  }
}
onMounted(() => {
  fetchTaDayList()
})
</script>

<template>
  <div class="list-warp">
    <div class="list-header">
      <h2>今日注册志愿者信息</h2>
    </div>
    <div class="list-table-wrapper">
      <div class="table-header">
        <div class="header-cell name">名字</div>
        <div class="header-cell address">常驻地址</div>
        <div class="header-cell number">联系电话</div>
        <div class="header-cell affiliated_organization">所属组织</div>
      </div>
      <div class="table-body">
        <Vue3-seamless-scroll
        :list="toDayList"
        :hover="true"
        :step="0.3"
        :limitScrollNum="5"
        :wheel="true"
        class="scroll-wrapper"
        style="height: 100%"
        >
         <div v-for="(item, index) in toDayList" :key="index" class="table-row">
            <div class="cell name">{{ item.volunteerName }}</div>
            <div class="cell address">{{ item.community }}</div>
            <div class="cell number">{{ item.contactNumber }}</div>
            <div class="cell affiliated_organization">{{ item.affiliatedOrganization }}</div>
         </div>


        </Vue3-seamless-scroll>
      </div>
    </div>
  </div>

</template>

<style scoped lang="less">
.list-warp {
  background-color: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  .list-header {
    text-align: center;
    margin-bottom: 12px;

    h2 {
      font-size: 20px;
      font-weight: bold;
      color: #333;
    }
  }

  .list-table-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    .table-header {
      display: flex;
      padding: 10px 15px;
      background-color: #f5f7fa;
      font-weight: 600;
      color: #333;
      border-bottom: 1px solid #e4e7ed;

      .header-cell {
        flex: 1;
        text-align: center;

        &.name {
          flex: 1.2;
        }

        &.address {
          flex: 1.8;
        }

        &.number {
          flex: 1.5;
        }

        &.affiliated_organization {
          flex: 1.8;
        }
      }
    }

    .table-body {
      flex: 1;
      overflow: hidden;

      .scroll-wrapper {
        height: 100%;

        .table-row {
          display: flex;
          padding: 10px 15px;
          color: #606266;
          font-size: 14px;
          text-align: center;

          &:nth-child(odd) {
            background-color: #fafafa;
          }

          &:nth-child(even) {
            background-color: #ffffff;
          }

          .cell {
            flex: 1;

            &.name {
              flex: 1.2;
            }

            &.address {
              flex: 1.8;
            }

            &.number {
              flex: 1.5;
            }

            &.affiliated_organization {
              flex: 1.8;
            }
          }
        }
      }
    }
  }
}
</style>